package fr.umlv.m2.jee.portailEtudiant.service.Impl;

import fr.umlv.m2.jee.portailEtudiant.persistence.CourseDocument;
import fr.umlv.m2.jee.portailEtudiant.persistence.ICourseDocumentDAO;
import fr.umlv.m2.jee.portailEtudiant.service.DisplayCourseDocument;
import fr.umlv.m2.jee.portailEtudiant.service.IDisplayCourseDocumentService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 18/04/11
 * Time: 11:42
 * To change this template use File | Settings | File Templates.
 */
@Service("defaultDisplayCourseDocumentService")
class DefaultDisplayCourseDocumentService implements IDisplayCourseDocumentService {

    @Autowired
    @Qualifier("hibernateCourseDocumentDAO")
    private ICourseDocumentDAO courseDocumentDAO;


    @Override
    @Transactional(readOnly=true)
    public List<DisplayCourseDocument> getAllDisplayCourseDocument() {
       List<DisplayCourseDocument> result = new ArrayList<DisplayCourseDocument>();

        for(CourseDocument listCourse : courseDocumentDAO.findAll()) {
            result.add(new DisplayCourseDocument(listCourse));
        }
        return result;
    }
}
